package com.zhang.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Arrays;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zhang.domain.SubjectArticle;
import com.zhang.mapper.SubjectArticleMapper;
import com.zhang.service.ISubjectArticleService;
import xin.altitude.cms.common.entity.AjaxResult;
import java.util.List;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import xin.altitude.cms.common.entity.PageEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@RestController
@RequestMapping("/zhang/subject/article")
public class SubjectArticleController{
    @Autowired
    private ISubjectArticleService subjectArticleService;
    @GetMapping("/page")
    public AjaxResult page(PageEntity pageEntity,SubjectArticle subjectArticle){
        return AjaxResult.success(subjectArticleService.page(pageEntity.toPage(), Wrappers.lambdaQuery(subjectArticle)));
    }
    @GetMapping("/list")
    public AjaxResult list(SubjectArticle subjectArticle){
        return AjaxResult.success(subjectArticleService.list(Wrappers.lambdaQuery(subjectArticle)));
    }
    @PostMapping("/push")
    public AjaxResult add(@RequestBody SubjectArticle subjectArticle) {
        return AjaxResult.success(subjectArticleService.save(subjectArticle));
    }
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody SubjectArticle subjectArticle) {
        return AjaxResult.success(subjectArticleService.updateById(subjectArticle));
    }
    @DeleteMapping("/delete/{ids}")
    public AjaxResult delete(@PathVariable Long[] ids) {
        return AjaxResult.success(subjectArticleService.removeByIds(Arrays.asList(ids)));
    }
    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id) {
        return AjaxResult.success(subjectArticleService.getById(id));
    }
    @GetMapping("/vo/page")
    public AjaxResult pageVo(PageEntity pageEntity,SubjectArticle subjectArticle){
        return AjaxResult.success(subjectArticleService.pageVo(pageEntity.toPage(), subjectArticle));
    }
    @GetMapping("/vo/list")
    public AjaxResult listVo(SubjectArticle subjectArticle){
        return AjaxResult.success(subjectArticleService.listVo(subjectArticle));
    }
    @GetMapping(value = "/vo/detail/{id}")
    public AjaxResult detailVo(@PathVariable("id") Long id) {
        return AjaxResult.success(subjectArticleService.getOneVo(id));
    }
}
